// pages/details/details.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    detailsObj: {}

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    // console.log(options);
    this.getDetailsList(options.id)
  },
  // 获取商品详情数据
  getDetailsList(_id) {
    wx.request({
      url: 'https://api.it120.cc/noodles/shop/goods/detail?id=' + _id,
      method: "GET",
      data: {},
      success: (res) => {
        // console.log(res.data.data.basicInfo);
        this.setData({
          detailsObj:res.data.data.basicInfo
        })
      }
    })
  },
  // 点击加入购物车
  onShop(e){
    console.log(e.currentTarget.dataset.obj);
    wx.setStorageSync('arr', e.currentTarget.dataset)
  },
  //点击跳转购物车页面
  gotoShop(){
    wx.switchTab({
      url: '/pages/shopCart/shopCart?id='+e.currentTarget.dataset.id,
    })
  }
})